<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
 	 <%@ include file="/common/import.jsp"%>
    <link rel="stylesheet" href="${ctx}/css/style.css" type="text/css">
	<script src="${ctx}/js/tab.js"></script>
	<script type="text/javascript" src="${ctx}/js/util.js"></script>
	
    <title>新增会员</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	 <script>
	$(function(){
		
		//初始化数据字典，无论新增或修改
		var dictUrl = "${ctx}/dict/item/list!tree.action";
		DictUtil.getDictExtList("#certType", dictUrl, {cateEname:"certType"});//证件类型
		DictUtil.getDictExtList("#str50_4", dictUrl, {cateEname:"education"});//教育情况
		DictUtil.getDictExtList("#str100_7", dictUrl, {cateEname:"bank"});//开户银行
		DictUtil.getCheckboxList("#memberRoleArray",'memberRoles', dictUrl, {cateEname:"memberType"});//开户银行
		
		//如果修改的话，需要传主键。
		var memberId = '${param.memberId}';
		if(memberId!=null && memberId!=""){
			var showMember = '${ctx}/admin/member/selectById.action?memberId='+memberId;
			var showMemberRole = '${ctx}/admin/memberRole/list.action?memberId='+memberId;
			//反显会员信息
			$.ajax({
				type:'post',
				url:showMember,
				//data:$('#'+formname).serialize(),
				dataType:'json',
				success:function(data){
				     var member = data.rows;
					 FormUtil.fillData("#add", member);
					 //反显
					 DictUtil.checkRadioDict("memberType", member.memberType);
					 DictUtil.checkSelectDict("#certType", member.certType);
					 DictUtil.checkSelectDict("#str50_4", member.str50_4);
					 DictUtil.checkSelectDict("#str100_7", member.str100_7);
					 //DictUtil.checkCheckboxDict("memberRoles", ['1','2']);
				}
			});	
			
	
			//反显会员角色
			$.ajax({
				type:'post',
				url:showMemberRole,
				dataType:'json',
				success:function(data){
				     var memberRoles = data.rows;
						var rolesArray = new Array();
				     for(var i=0;i<memberRoles.length;i++){
				    	 var roleEname=memberRoles[i].roleEname;
				    	 rolesArray[i] = roleEname;
				     }
				     
					 DictUtil.checkCheckboxDict("memberRoles", rolesArray);
				}
			});	
			
		}
	})
	
	function submitForm(formname){	

		var saveUrl = "${ctx}/admin/member/add.action";
		if(!confirm("确实要提交吗？")) return;	
		var memberId = $("#memberId").val();
		if(memberId!=null && memberId!=""){
			saveUrl = "${ctx}/admin/member/edit.action";
		}
			$.ajax({
				type:'post',
				url:saveUrl,
				async: false,
				data:$('#'+formname).serialize(),
				dataType:'json',
				success:function(data){
				      var flag = data.flag;
				      var msg = data.msg;
				      //handleResult(flag,msg);
				      if(flag=="T"){
				        alert("操作成功");
				        window.location.href="${ctx}/sendPage/member/member-list";
				     }else{
				        alert("操作失败");
				     }
					}
				});	
	}
</script>


  </head>
  
  <body>
   <div id="addDiv" name="addDiv" style="width:70%;margin:0 auto">
   	 <form class="form-horizontal" role="form" method="post" id="add" action="javascript:void(0)">
	    <input type="hidden" name="formToken" value="${formToken}" />
		<input name="deptName" id="deptName" type="hidden" value="${loginUser.deptCname}" />
		<input name="deptId" id="deptId" type="hidden" value="${loginUser.deptId}" />
		<input name="memberLevel" id="memberLevel" type="hidden" value="2" />
		<input name="editType" id="editType" type="hidden" value="1" />
		<input name="memberId" id="memberId" type="hidden" value="${param.memberId }" />
		<div class="form-group" style="text-align: center;">
				<div class="biaoge">
					<div class="jbxx_ul">
						<ul>
							<li class="cur" id="tabmenu_10" name="tabmenu_10"
								onclick=setTimeout("Show_Tab(1,0,4,'','cur')",100)><a>基本信息</a>
							</li>
							<li id="tabmenu_11" name="tabmenu_11" onclick=setTimeout("Show_Tab(1,1,4,'','cur')",100)><a>联系信息</a>
							</li>
							<li id="tabmenu_12" name="tabmenu_12" onclick=setTimeout("Show_Tab(1,2,4,'','cur')",100)><a>财务信息</a>
							</li>
							<li id="tabmenu_13" name="tabmenu_13" onclick=setTimeout("Show_Tab(1,3,4,'','cur')",100)><a>银行信息</a>
							</li>
						</ul>
					</div>
					
					<div class="jbxx_cont" id="tabcontent_10" style="display:block">
						<jsp:include page="member-base-save.jsp"></jsp:include>
						<jsp:include page="member-base-person-save.jsp"></jsp:include>
					</div>	
					
					<div class="jbxx_cont" id="tabcontent_11" style="display:none">
						<table cellpadding="0" cellspacing="1" class="info">
							<tr>
								<th colspan="4">联系信息</th>
							</tr>
							<tr >
								<th><label for="mobile" class="">移动电话</label>
								</th>
								<td><input type="text"  id="mobile" name="mobile" 
								 class="easyui-validatebox" validType="mobile" missingMessage="请填写移动电话" invalidMessage="请输入正确的手机号">
								</td>
								<th><label for="phone" class="">固定电话</label>
								</th>
								<td><input type="text" id="phone" name="phone"	
								class="easyui-validatebox" validType="tel" missingMessage="请填写固定电话" invalidMessage="请输入正确的固定电话">

								</td>
							</tr>
							<tr >
								<th><label for="email" class="">邮箱</label>
								</th>
								<td><input type="text" id="email" name="email"
								class="easyui-validatebox" validType="EMAIL" missingMessage="请填写邮箱" invalidMessage="请输入正确的邮箱地址">
								</td>
								<th><label for="str50_15" class="">邮政编码</label>
								</th>
								<td><input type="text"  id="str50_15"
									name="str50_15" 
									class="easyui-validatebox" validType="ZIP" missingMessage="请填写邮政编码" invalidMessage="请输入正确的邮政编码">
								</td>
							</tr>
						</table>
						<jsp:include page="member-contact-person-save.jsp"></jsp:include>
					</div>

					<div class="jbxx_cont" id="tabcontent_12" style="display:none">
						<table cellpadding="0" cellspacing="1" class="info">
							<tr>
								<th colspan="4">财务信息</th>
							</tr>
						</table>
						<jsp:include page="member-finance-person-save.jsp"></jsp:include>
					</div>

					<div class="jbxx_cont" id="tabcontent_13" style="display:none">
						<table width="100%" border="0" cellspacing="0" cellpadding="0"	class="info">
							<tr>
								<th colspan="4">银行信息</th>
							</tr>
							<tr >
								<th width=""><label for="str50_20" class="">银行结算账户户名（全称）</label>
								</th>
								<td width=""><input type="text" class="" style="width: 150px;" id="str50_20"
									name="str50_20" value="">
								</td>
							</tr>
							<tr>
								<th><label for="str100_7" class="">开户银行</label>
								</th>
								<td><select id="str100_7" name="str100_7"
									style="width: 150px;text-align: center;">
										<option value="">--请选择--</option>
								</select>
								</td>
							</tr>
							<tr >
								<th><label for="str100_8" class="">银行账号</label>
								</th>
								<td><input type="text" class="" style="width: 150px;" id="str100_8"
									name="str100_8" value="">
								</td>
							</tr>
						</table>
						<br>
						<center>
							<a class="easyui-linkbutton" iconCls="icon-add" onclick="$('#editType').val('0');submitForm('add');">保存</a>
							<a class="easyui-linkbutton" iconCls="icon-add" onclick="$('#editType').val('1');submitForm('add');">提交</a>
						</center>
					</div>	
			 </div>	
		</form>	
	</div>			
  </body>
 
</html>
